﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;

using CloudSoft.Workflows;

namespace ERPStore.Exporter.Workflows.Activities
{

	public sealed class GetLeadSource : CodeActivity
	{
		public InArgument<string> LeadSourceId { get; set; }
		public OutArgument<ERPStore.Models.LeadSourceBase> LeadSource { get; set; }

		protected override void Execute(CodeActivityContext context)
		{
			string leadSourceId = context.GetValue(this.LeadSourceId);

			var leadSourceRegistrationService = context.GetService<ERPStore.Services.ILeadSourceRegistrationService>();
			var leadSource = leadSourceRegistrationService.List.Single(i => i.Id == leadSourceId);

			context.SetValue(LeadSource, leadSource);

			context.ReportProgress(string.Format("Leadsource : {0}", leadSource.Name));
		}
	}
}
